import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥生成 http://tool.chacuo.net/cryptrsapubkey

// 公钥
const publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuSoXd30nJHz3HatWZZCy\n" +
    "xM4elMSiGxAckQy5v31AhVHKg/l3iGvJnIBElPRcOGlr2De6LyCIO7dXUaVgJMFg\n" +
    "06Kv2B9hakdDEfhz0f0P2vVPcLK/eB+8/Y72neU6b1NipznQnm6bHmoRoCtwgbkm\n" +
    "d8bQh41ku0stgCXlMZ7QRbO3SvjCu71BgoYgfAIA+rQRnHvmU84C3+0B5RlFbjkp\n" +
    "y1wTU/sHv0KukRv1PU1ArJPDKKLh5xLsRka/+N04k84N/v9mhxQmd5pYW3jPNd1e\n" +
    "706p5httrs/iXWbmZUqicuomwpnjgyYpQ54YeXqcES6Vf5Yn2OKVihp8vfKYXdGR\n" +
    "8wIDAQAB";

// 私钥
const privateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC5Khd3fSckfPcd\n" +
    "q1ZlkLLEzh6UxKIbEByRDLm/fUCFUcqD+XeIa8mcgESU9Fw4aWvYN7ovIIg7t1dR\n" +
    "pWAkwWDToq/YH2FqR0MR+HPR/Q/a9U9wsr94H7z9jvad5TpvU2KnOdCebpseahGg\n" +
    "K3CBuSZ3xtCHjWS7Sy2AJeUxntBFs7dK+MK7vUGChiB8AgD6tBGce+ZTzgLf7QHl\n" +
    "GUVuOSnLXBNT+we/Qq6RG/U9TUCsk8MoouHnEuxGRr/43TiTzg3+/2aHFCZ3mlhb\n" +
    "eM813V7vTqnmG22uz+JdZuZlSqJy6ibCmeODJilDnhh5epwRLpV/lifY4pWKGny9\n" +
    "8phd0ZHzAgMBAAECggEAGk3Oc50F2HsgJ8jVRyxdGPQnB/8/ABUz2a8zG+7RIZ9S\n" +
    "45im0GxvgZn/JCHqj+D5/wc7ncJDWChdcS3LEK2f8bCkxlD+57gj4QOogGYwwGwk\n" +
    "0t+xr4Diuip7Akc0G+h+lT7zUe5oftOWmWhSXTtOKanGqdr+OlUdq5y2iGwFLkFx\n" +
    "RCW/Nmu9YbD6RNApudP2b28LT4HsdT0GP2JjUPiHqBR92R8lTsOPHGjhpZxzDOn2\n" +
    "JLlH86cfYPVCTtiupVckSiQhtS4BSRtZWlGWk1zZu/kKxw+ejNG8OWk6PlbUKWpc\n" +
    "XBwePoAD8b0/+OKu6XZGzZX1E8RqogbX9bfDGQY7YQKBgQDzZb5byj0EI41HB6p9\n" +
    "FBD2eqk/lO2NZAlvPUq5UX80dhRFwMPr5D8OHIpvbtNfJBwPP0YrW/AqUOFOvEQx\n" +
    "0DIO33O+XfrRdbMeKQlilSQDuCfn8N+phJidmdICL5CI4QdYY3OoBRPNYNtQ9R85\n" +
    "ihZonErUcrzf0MW8YqSo1Xc0SQKBgQDCwHa/sziIO/xQsEYtVvHZ3r5kkmg92jgP\n" +
    "CseZRggWpKI3VyJBCM0FQuiT3yMGuhmT8Nt1BOtZhYUHiLzzrirT6stKMZN2W81P\n" +
    "7dTBPQjZL3xdGE8ilCCxLo+tLBLK3ad5Hfeye91jCrWImXT2g6bvIfebEIjaqwv+\n" +
    "bh7IaOocWwKBgQCG6DzzmYvqUF5NIXWg8E9anrBSupRUyz7jdmCFiSNti4k/BFJT\n" +
    "3GYKx0z/6Lilwlj/Jn4ZKFNc0Qmg338Y8SHd1oLL4EFWedt2+x3lk26r1RXhXERM\n" +
    "LF9+8zRQ29ZL2BZ/Klh/p5jLPEUzgTn2ZZB4GTDswk/n6kq/WRmVLwRsaQKBgQCS\n" +
    "ZDgfC2oQRf747DgkNrnfiqbVVJRVAianb/PvjAvicWiabr4J4sKyFMRc+xsKIHO/\n" +
    "mApu4P7EMTB5JFjcV2xMFa8wGyn8iy8+yMjnZKi1ERPLqs05cd1NMnG/u2R457rO\n" +
    "uS8LFD6rB07D2o5oCzg9guvrvLcSoAaI/1/WR77LBwKBgE1/Th05xl+QuVs0oX9O\n" +
    "+D7/PD5BjorcG6IDI1rQmHl0vcFtksfVSoH1SMOUsv+fX9iumzm0ot/dFgChNhMj\n" +
    "de72O3bkUbC0RGwfvBw8d7uAkxX9TUJs6sDazwCZYlO/WAWFsyYMxZUWhUsksB0U\n" +
    "DtKxjIG2BUQk4I/VlDA+Z8Jj";

const rasInstance = new JSEncrypt();
// 加密
export function encrypt(txt) {
    rasInstance.setPublicKey(publicKey);
    return rasInstance.encrypt(txt);
}

// 解密
export function decrypt(txt) {
    rasInstance.setPrivateKey(privateKey);
    return rasInstance.decrypt(txt);;
}